package id.co.rho.scoring.cid.client.helper;

import com.extjs.gxt.ui.client.data.BaseTreeModel;
import com.extjs.gxt.ui.client.event.EventType;
import com.google.gwt.user.client.ui.AbstractImagePrototype;

/**
 * Created by IntelliJ IDEA.
 * User: User3
 * Date: 20/07/11
 * Time: 16:33
 *
 * @author : Frizky
 * @email : frizkey@gmail.com
 */
public class ModelMenuItem extends AbstractModelMenu {
	String functionCode;
	
    public ModelMenuItem(String name) {
        set("id", ID++);
        set("name", name);
    }

    public ModelMenuItem(String name, EventType events) {
        set("id", ID++);
        set("name", name);
        set("event", events);
    }

    public ModelMenuItem(String name, EventType events, AbstractImagePrototype image) {
        set("id", ID++);
        set("name", name);
        set("event", events);
        set("image", image);
    }
    
    public ModelMenuItem(String name, EventType events, AbstractImagePrototype image, String functionCode) {
        set("id", ID++);
        set("name", name);
        set("event", events);
        set("image", image);
        this.functionCode = functionCode;
    }

    /**
     * constructor untuk custom id
     *
     *
     * @param id Pastikan idnya <b>TIDAK DOBEL!!!</b>
     * @param name
     * @param events
     * @param image
     */
    public ModelMenuItem(String id, String name, EventType events, AbstractImagePrototype image) {
        set("id", id);
        set("name", name);
        set("event", events);
        set("image", image);
    }
    
    public ModelMenuItem(String id, String name, EventType events, AbstractImagePrototype image, String functionCode) {
        set("id", id);
        set("name", name);
        set("event", events);
        set("image", image);
        this.functionCode = functionCode;
    }

    public ModelMenuItem(String name, EventType events, BaseTreeModel[] children) {
        this(name, events);
        for (int i = 0; i < children.length; i++) {
            add(children[i]);
        }
    }

    public ModelMenuItem(String name, EventType events, AbstractImagePrototype image, BaseTreeModel[] children) {
        this(name, events, image);
        for (int i = 0; i < children.length; i++) {
            add(children[i]);
        }
    }
    
    public ModelMenuItem(String name, EventType events, AbstractImagePrototype image, String functionCode, BaseTreeModel[] children) {
        this(name, events, image, functionCode);
        for (int i = 0; i < children.length; i++) {
            add(children[i]);
        }
    }

    public void add(BaseTreeModel children) {
        super.add(children);
    }

    public void add(BaseTreeModel[] children) {
        for (int i = 0; i < children.length; i++) {
            add(children[i]);
        }
    }

    public EventType getEvent() {
        return get("event");
    }

	public String getFunctionCode() {
		return functionCode;
	}
    
}
